<template>
  <div class="app-container">
    <el-card>
      <div slot="header" class="clearfix">
        <span>抽卡记录</span>
      </div>

      <div class="filter-container">
        <el-input v-model="listQuery.user" :placeholder="'请输入用户信息'" clearable style="width: 200px;margin-right: 10px;" class="filter-item" @keyup.enter.native="handleFilter" />
    
        <el-select v-model="listQuery.card_id" style="margin-right: 10px;" clearable placeholder="卡片">
            <el-option v-for="item in card " :key="item.id" :value="item.id" :label="item.name"></el-option>
        </el-select>


        <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
          {{ '搜索' }}
        </el-button>
        <el-button v-waves :disabled="!checkPermission(['question.export'])"  type="success" icon="el-icon-upload2" @click="handleExport">
            {{ '导出' }}
        </el-button>
      </div>

      <el-table
        v-loading="listLoading"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}"
        :data="list"
        border
        fit
        highlight-current-row
        style="width: 100%"
        row-key="id"
        :tree-props="{children: 'children'}"
      >

        <el-table-column width="100" label='编号'>
          <template slot-scope="scope">
            <span>{{ scope.row.id }}</span>
          </template>
        </el-table-column>
        <el-table-column  label='用户'  align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.nickname }}</span>
          </template>
        </el-table-column>
        <el-table-column  label='卡片' align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.card_name}}</span>
          </template>
        </el-table-column>

      
      
        <el-table-column  label='抽中时间' align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.log_time|parseTime}}</span>
          </template>
        </el-table-column>
    

      </el-table>

      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </el-card>
  </div>
</template>

<script>
import {export_excell} from '@/api/export_excell' // 导出
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import permission from '@/directive/permission/index.js' // 权限判断指令
import checkPermission from '@/utils/permission' // 权限判断函数
import { card_log } from '@/api/card'
import { parseTime } from '@/utils'
export default {
  name: 'card_log',
  components: { Pagination },
  directives: { waves, permission },
  filters: {
    parseTime
  },
  data() {
    return {
      list: [],
      card : [],
      total: 0,
      select_ids:[],
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
     handleExport(){
      //导出
           export_excell(process.env.VUE_APP_BASE_API + 'admin/card_log_export',this.listQuery);
      },
    checkPermission,
    getList() {
      this.listLoading = true
      card_log(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.data.total
        this.card = response.data.card
        this.listLoading = false
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
 
  }
}
</script>
